import 'package:flutter/material.dart';
import 'package:shop/util/color.dart';

typedef ShopCallBack = void Function(String text);

class SearchView extends StatelessWidget {
  ShopCallBack callback;

  SearchView({super.key, required this.callback});

  @override
  Widget build(BuildContext context) {
    return Container(
      color: HexColor.fromHex('#C00000'),
      child: Container(
        width: MediaQuery.of(context).size.width,
        height: 30,
        margin: EdgeInsets.all(10),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(15),
        ),
        child: SearchBar(
          leading: Icon(Icons.search),
          hintText: '输入搜索内容',
          onSubmitted: (text) {
            callback(text);
          },
        ),
      ),
    );
  }
}
